<?php



namespace app\common;
use app\common\traits\ResponseJson;
use think\exception\Handle;
use think\Request;
use think\Response;
use think\facade\Db;
use Throwable;

class ExceptionHandle extends Handle
{
    

    /**
     * Render an exception into an HTTP response.
     * @access public
     * @param Request $request
     * @param Throwable $e
     * @return Response
     */
    public function render($request, Throwable $e): Response
    {   
        if ($request->isAjax() && app('http')->getName() == 'api') {
            return json( ['code' => 500, 'line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]);
        }
        return parent::render($request, $e);
       
    }
}
